// 引入
import { createRouter, createWebHistory } from 'vue-router'

//引入组件
import About from '@/pages/About.vue'
import Home from '@/pages/Home.vue'
import News from '@/pages/News.vue'
import Detail from '@/pages/Detail.vue'


// 创建路由器
const router = createRouter({
  history: createWebHistory(), // 路由器的规则模式
  routes: [ // 管理路由 对应的关系 key value
    {
      name: 'zhuye',
      path: '/home',
      component: Home
    },
    {
      name: 'xinwen',
      path: '/news',
      component: News,
      children: [
        {
          name: 'xiang',
          path: 'detail', // ？表示的是 可传可不传
          component: Detail,
          props(route) { // 也就是写成函数的形式
            return route.query
          }
          // props: true
          //
        }
      ]
    },
    {
      name: 'guanyu',
      path: '/about',
      component: About
    }
  ]
})

export default router